import axios from 'axios';


const httpClient = axios.create({
    baseURL: '/',
    headers: {
        'Content-Type': 'application/json',
        // "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Windows; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.114 Safari/537.36"
    }
});

httpClient.interceptors.request.use(
    (config) => config,
    (error) => Promise.reject(error)
);

httpClient.interceptors.response.use(
    (response) => {
        if (response?.status === 200) {
            // Handle successful response
            return response.data;
        } else {
            console.error('Request failed:', response);
            return Promise.reject(new Error('Request failed'));
        }
    },
    (error) => {
        console.error('Response error:', error);
        return Promise.reject(error);
    }
);

export default httpClient;
